#include <iostream>
#include <unordered_map>
#include <string>

bool is_prime(int number) {
    if (number <= 1) {
        return false;
    }
    for (int i = 2; i <= sqrt(number); i++) {
        if (number % i == 0) {
            return false;
        }
    }
    return true;
}

int next_prime(int number) {
    while (true) {
        number++;
        if (is_prime(number)) {
            return number;
        }
    }
}

void mainFunction(std::string words) {
    std::unordered_map<std::string, std::string> num_word = {
        {"zero", "0"},
        {"one", "1"},
        {"two", "2"},
        {"three", "3"},
        {"four", "4"},
        {"five", "5"},
        {"six", "6"},
        {"seven", "7"},
        {"eight", "8"},
        {"nine", "9"}
    };

    try {
        std::string num_str;
        for (char word : words) {
            num_str += num_word[word];
        }

        if (num_str.size() == 3) {
            int number = std::stoi(num_str);
            int closest_prime = is_prime(number) ? number : next_prime(number);
            while (true) {
                int prev_number = number - 1;
                if (prev_number > 1 && is_prime(prev_number)) {
                    std::cout << prev_number << std::endl;
                    break;
                }
                if (is_prime(closest_prime)) {
                    std::cout << closest_prime << std::endl;
                    break;
                }
                closest_prime++;
                number--;
            }
        } else {
            std::cout << "Wrong input" << std::endl;
        }
    } catch (...) {
        std::cout << "Wrong input" << std::endl;
    }
}

int main() {
    std::string inputStr;
    std::cin >> inputStr;
    mainFunction(inputStr);
    return 0;
}
